// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2004-11-24

#ifndef __SVR_RELEASEUSER_H_COMMON_SVR_BASE__
#define __SVR_RELEASEUSER_H_COMMON_SVR_BASE__

#pragma once

#include "base_thread.h"

namespace JoyServer
{

class CJoyUser;

class CJoyReleaseUser : public CJoyThread
{
protected:
    typedef CList<CJoyUser*>    CUserList;

    CJoyCriticalSection m_lock;
    CUserList   m_users;
    HANDLE      m_event;
    volatile bool m_stop;

    CJoyUser* PeekUser();
    void ReleaseUsers();

    virtual DWORD ThreadProc();
public:
    CJoyReleaseUser();
    virtual ~CJoyReleaseUser();

    virtual bool Create();
    virtual void Destroy();

    void AddUser(CJoyUser* pUser);
};

} // namespace JoyServer

#endif  // __SVR_RELEASEUSER_H_COMMON_SVR_BASE__